package pl.org.lutra.planner.gui.toolbar;

import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.RichTooltip;

import pl.org.lutra.planner.gui.resources.Text;

public class ToolbarButton extends JCommandButton {
    private static final long serialVersionUID = -6108363405997784846L;
    
    public ToolbarButton(String keyPrefix) {
        super(Text.get(keyPrefix + ".title"));
        
        decorate(keyPrefix);
    }
    
    private void decorate(String keyPrefix) {
        RichTooltip richTooltip = new RichTooltip();
        
        richTooltip.setTitle(Text.get(keyPrefix + ".toolTip"));
        
        String description = Text.get(keyPrefix + ".description");
        String[] sections = description.split("\\n");
        for (int i = 0; i < sections.length; i++) {
            richTooltip.addDescriptionSection(sections[i]);
        }
        
        setActionRichTooltip(richTooltip);
    }
}
